

from celery_tasks.main import celery_app
import logging

from celery_tasks.sms.yuntongxun.sms import CCP

logger = logging.getLogger('django')
@celery_app.task(name='send_sms_code')
def send_sms_code(mobile, sms_code, sms_code_expires):
    SMS_CODE_TEMP_ID = 1
    try:
        res = CCP().send_template_sms(mobile, [sms_code, sms_code_expires], SMS_CODE_TEMP_ID)
    except Exception as e:
        logger.error('短信验证码发送异常: [mobile: %s sms_code: %s]' % (mobile, sms_code))
    else:

        if res != 0:
            logger.error('短信验证码发送失败: [mobile: %s sms_code: %s]' % (mobile, sms_code))
        else:
            logger.info('短信验证码发送成功: [mobile: %s sms_code: %s]' % (mobile, sms_code))



